<template>
    <el-menu
      background-color="#000"
      text-color="#CCC"
      active-text-color="#2e61f3"
      class="el-menu-demo"
      mode="horizontal"
      :default-active="currentPath"
      router
    >
      <el-menu-item v-for="route in routes" :index="route.path"  :key="route.path"><i :class="route.icon"></i>{{route.title}}</el-menu-item>
    </el-menu>
</template>

<script>
export default {
  data() {
    return {
      currentPath: "/"
    };
  },
  computed: {
    routes(){
      return this.$router.options.routes;
    }
  },
  watch: {
    $route(val){
      this.currentPath = val.path;
    }
  }
};
</script>

<style scoped>
.el-menu-item{
  font-size: 22px;
}
</style>>